***********************************************
***** Pandora's Rules in the Laboratory  ******
***********************************************

** Run this file to replicate Figures 1, 2, 4, 5
** Input file: Full.dta


** Change working directory
cd "..."
use "Main.dta", clear

*Figure 1
histogram pos2 if session == "191125_1015", graphregion(fcolor(white))
**same as histogram pos2 if session == "191125_1308"
histogram pos2 if session == "191129_0948", graphregion(fcolor(white))
**same as histogram pos2 if session == "191129_1312"

*Figure 2a and 2b
twoway scatter pos2 if session == "191125_1015", graphregion(fcolor(white)) legend(off)) xtitle(Rounds)
**same as histogram pos2 if session == "191125_1308", graphregion(fcolor(white)) legend(off)) xtitle(Rounds)
twoway scatter pos2 Period if session == "191129_0948", graphregion(fcolor(white)) legend(off)) xtitle(Rounds)
**same as twoway scatter pos2 Period if session == "191129_1312", graphregion(fcolor(white)) legend(off)) xtitle(Rounds)

*Figure 4a and 4b
twoway (scatter correct1_r0 Period) (lfitci correct1_r0 Period), by(treatment, graphregion(fcolor(white)) legend(off))  xtitle(Rounds)  ylabel(0(0.5)1) 
twoway (scatter correct2_r0 Period) (lfitci correct2_r0 Period), by(treatment, graphregion(fcolor(white)) legend(off))  xtitle(Rounds)  ylabel(0(0.5)1)

*Figure 5
bys treatment: tab openedboxes
gen x1 = 60.17     if treatment == 0
gen x2 = 39.83     if treatment == 0
replace x1 = 98.27 if treatment == 1
replace x2 = 1.73  if treatment == 1
graph bar x1 x2, over(treatment,  relabel(1 "Strict" 2 "Flexible")) legend(label(1 "One box") label(2 "Two boxes")) ytitle(Percentage of opened boxes)blabel(total) graphregion(color(white))





************* End of Do file ***************
